﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TR.AppService.AppService.CKGL;
using TR.AppService.AppService.Wh_Buy_Order_h;
using TR.AppService.Dto;
using TR.AppService.Dto.RKGLDto;
using TR.Domain.Entity.CKGL;
using TR.Domain.Entity.RK;

namespace TR.WebApi.Controllers.CKGLControllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class wh_Outbill_hController : ControllerBase
    {
        private readonly Iwh_Outbill_hAppService iwoh;

        public wh_Outbill_hController(Iwh_Outbill_hAppService iwoh)
        {
            this.iwoh = iwoh;
        }

        //出库管理新增
        [HttpPost]
        public async Task<bool> CKGLInsert([FromBody] CKGLData ckxz)
        {
            bool result = await iwoh.CKGLInsert(ckxz.jcxx, ckxz.ckmx);
            if (result)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        [HttpGet]
        //出库关联单号查询
        public async Task<DtoFenYe<CKDHGuanlian>> CKGuanlian(int mys, int dqy, string? dqsj, string? jssj, [FromQuery] CKGLDHTjDto tj)
        {
            return await iwoh.CKGuanlian(mys, dqy, dqsj, jssj, tj);
        }

        //根据销售订单查询对应的商品
        [HttpGet]
        public async Task<List<XSDHchaHP>> XSDHChahp(string sale_code, [FromQuery] HPTj tj)
        {
            return await iwoh.XSDHChahp(sale_code, tj);
        }

        //出库主表查询
        [HttpGet]
        public async Task<DtoFenYe<CKGL_SelectZB>> CKGLSelect(int mys, int dqy, CKGLZbTjCx tj)
        {
            return await iwoh.CKGLSelect(mys, dqy, tj);
        }

    }
}
